<%@ page language="java" import="java.util.*,com.animal.dao.*,com.animal.bean.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>

<jsp:useBean id="PageServlet" scope="page" class="com.animal.controller.PageServlet_exp" />

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>实验档案管理</title>

<link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap.min.css">
<link href="./bootstrap/css/styles.css" rel="stylesheet">

</head>

<body>
	<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar-collapse">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="ExperimentalFileManager.html"><span>实验动物</span>档案管理</a>
				<ul class="user-menu">
					<li class="dropdown pull-right">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> User <span class="caret"></span></a>
						<ul class="dropdown-menu" role="menu">
							<li><a href="http://www.cau.edu.cn"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
							<li><a href="#"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
							<li><a href="login.jsp"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
						</ul>
					</li>
				</ul>
			</div>				
		</div>
	</nav>
		
	<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
		<form role="search">
			<div class="form-group">
				<input type="text" class="form-control" placeholder="Search">
			</div>
		</form>
		<ul class="nav menu">
			<li class="parent ">
				<a href="ExperimentalFileManagement.jsp">
					<span class="glyphicon glyphicon-list"></span> 管理员信息 <span data-toggle="collapse" href="#sub-item-1" class="icon pull-right"><em class="glyphicon glyphicon-s glyphicon-plus"></em></span> 
				</a>
				<ul class="children collapse" id="sub-item-1">
					<li>
						<a class="" href="ExperimentalPersonalInfo.jsp">
							<span class="glyphicon glyphicon-share-alt"></span> 个人信息
						</a>
					</li>
					<li>
						<a class="" href="ExperimentalChangePassword.jsp">
							<span class="glyphicon glyphicon-share-alt"></span> 修改密码
						</a>
					</li>
				</ul>
			</li>
			
			<li class="parent ">
				<a href="ExperimentalFileManagement.jsp">
					<span class="glyphicon glyphicon-list"></span> 实验档案管理 <span data-toggle="collapse" href="#sub-item-2" class="icon pull-right"><em class="glyphicon glyphicon-s glyphicon-plus"></em></span> 
				</a>
				<ul class="children collapse" id="sub-item-2">
					<li>
						<a class="" href="ExperimentalFileManagement.jsp">
							<span class="glyphicon glyphicon-share-alt"></span> 管理档案
						</a>
					</li>

				</ul>
			</li>
			
			<li role="presentation" class="divider"></li>
			<li><a href="login.jsp"><span class="glyphicon glyphicon-user"></span>登录页面</a></li>
		</ul>
		<div class="attribution">Created by <a href="#">软工第9组</a></div>
	</div><!--/.sidebar-->
		
	
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
		<div class="row">
			<ol class="breadcrumb">
				<li><a href="ExperimentalFileManager.html"><span class="glyphicon glyphicon-home"></span></a></li>
				<li class="active">实验档案管理</li>
			</ol>
		</div>
		
		
		
		<!-- 从这开始添加代码 -->
		
		<div class="row">
			<div class="col-lg-12">
<!-- 				<h3><center><b>实验档案管理</b></center></h3>
				总体功能界面与查询界面类似<br>
				a)	需要增加表项“档案审核情况”，状态包括未审核、审核中、审核通过、审核不通过等<br>
				b)	在每个档案记录后增加按钮“归档”和“删除”：<br>
					“归档”：填写部分档案基本信息后存入数据库<br>
				使用animalfile09_laboratoryarchive表。 -->

				<table class="table table-striped">
				<!-- <table width="800px" bordercolor="#3399FF" border="2px" align="center"> -->
  					<h3><center><b>实验档案信息表</b></center></h3>
<% 
  					String filenumber=((String)request.getParameter("FileNumber")==null)?"":(String)request.getParameter("FileNumber");
					String filetitle=((String)request.getParameter("FileTitle")==null)?"":(String)request.getParameter("FileTitle");
					String userid=((String)request.getParameter("UserID")==null)?"":(String)request.getParameter("UserID");
					String animalid=((String)request.getParameter("AnimalID")==null)?"":(String)request.getParameter("AnimalID");
 %> 							
  					<table align="center" class="table table-striped" name="search">
					<tr>
						<form method="post">
							<td>
								<label for="FileNumber">档案编号:</label>
								<input type="text" name="FileNumber" class="form-control" value="<%=filenumber%>">
							</td>
							<td>
								<label for="FileTitle">档案名称:</label>
								<input type="text" name="FileTitle" class="form-control" value="<%=filetitle%>">
							</td>
							<td>
								<label for="UserID">用户编号:</label>
								<input type="text" name="UserID" class="form-control" value="<%=userid%>">
							</td>
							<td>
								<label for="AnimalID">动物编号:</label>
								<input type="text" name="AnimalID" class="form-control" value="<%=animalid%>">
							</td>
							<td>
								<input type="submit" class="btn btn-info" style="margin-top:37%" value="查询">
							</td>
						</form>
					</tr>
				</table>
				
  				<table align="center" class="table table-striped">
					  <thead>
					    <tr>
					      <th>编号</th>
					      <th>名称</th>
					      <th>用户编号</th>
					      <th>动物编号</th>
					      <th>实验日期</th>
					      <th>填写日期</th>
					      <th>状态</th>
					      <th>操作</th>
					    </tr>
					  </thead>
					  
				<tbody>

<%
        ArrayList list = (ArrayList)ExpManage.selectLike(filenumber,filetitle,userid,animalid);
        Iterator it = list.iterator();
        String fn;
        PageServlet.page(request);
        String footer = PageServlet.PageFooter();
        if (PageServlet.intPageCount>0) //总页数大于0
        {
            int i=0; 
            while(it.hasNext())
            {
              ExpBean file = (ExpBean)it.next();
              String state = file.getFileState();
              fn = file.getFileNumber();
              i++;
              if (i>((PageServlet.intPage-1)*PageServlet.intPageSize) &&(i<=PageServlet.intPage*PageServlet.intPageSize))  
              {
%>
                <tr>
                  <td><%=file.getFileNumber() %></td>
                  <td><%=file.getFileTitle() %></td>
                  <td><%=file.getUserID() %></td>
                  <td><%=file.getAnimalID() %></td>
                  <td><%=file.getExperimentDate() %></td>
                  <td><%=file.getFillingDate() %></td>
                  <%
                  if(state.equals("未审核")){
                  %>
                    <td><font color="red"><b><%=file.getFileState() %></b></font></td>
                    <td>
						<a class="btn btn-info" href="ExpServlet?do=archive&id=<%=fn%>">审核</a>
                   	    <a class="btn btn-danger" href="ExpServlet?do=del&id=<%=fn %>" onclick="javascript:return confirm('确认删除吗？');">删除</a>
                 	</td>  
                  <%  
                  }else{  //已审核，蓝色，禁用归档按钮
                  %>
                    <td><font color="blue"><b><%=file.getFileState()%></b></font></td>
                    <td>
                      <a class="btn btn-info"  style="pointer-events:none;opacity:0.2;">审核</a>
                    <a class="btn btn-danger" href="ExpServlet?do=del&id=<%=fn %>" onclick="javascript:return confirm('确认删除吗？');">删除</a>
                  </td>  
                  <%
                  }
                  %>
                </tr>
<%
              }
            }
        }
        out.println("<tr><td colspan=6>"+footer+"</td></tr>");
%>
					  </tbody>
				</table>			
								

			</div>
		</div>
	</div>
	
	<script src="./bootstrap/js/jquery-3.1.0.min.js"></script>
	<script src="./bootstrap/js/bootstrap.min.js"></script>

</body>

</html>
